## Universidade Federal do Rio Grande do Sul - Instituto de Informatica
## Departamento de Informatica Teorica
## Modelos de Linguagem de Programacao - 2013/1
## Professor: Lucas Schnorr
## Alunos: Felipe Schimidt e Mario Gasparoni Junior
##
##
## 
## Implementacao do modulo 'ammo' seguindo recomendacoes em:
## http://www.pygame.org/docs/
import pygame, commons

class Ammo:
	'Ammo class of the game'

	###ATTRIBUTES/CONSTANTS###
	
	#ammo (spoons) positions
	x_pos = 0
	y_pos = 0	

	def __init__(self, x_pos=None, y_pos=None, orientation=None):
		x_pos=100
		y_pox=100
		
	def __init__(self, x_pos=None, y_pos=None, orientation=None):
		if self.x_pos is not None:
			self.x_pos = x_pos
		if self.x_pos is not None:
			self.y_pos = y_pos
		if orientation is not None:
			self.orientation = orientation

	#This refreshes the spoon positions into the screen	
	def update(self, screen, fired_spoons):
		for i in range(len(fired_spoons)):
			throwed = fired_spoons[i]
			if throwed.orientation == 'south':
				throwed.draw_sprite_south(screen, throwed.x_pos, throwed.y_pos)
				if throwed.y_pos == commons.MAX_WIDTH:
					#TODO delete 'used' objects
					fired_spoons = fired_spoons
				else:
					throwed.y_pos += 1
					fired_spoons[i] = throwed
			else:
				throwed.draw_sprite_north(screen, throwed.x_pos, throwed.y_pos)
				if throwed.y_pos == -100:
					#TODO delete 'used' objects
					fired_spoons = fired_spoons
				else:
					throwed.y_pos -= 1
					fired_spoons[i] = throwed
